<script>
export default {
  name: "RagChat",
  data(){ //自定义的数据
    return{
       question:"腾讯是谁创建的", // 问题
       answer:"" //答案
    }
  },
  methods:{
       sendInfo(){ //发送信息
           const self = this;
          this.$http.get("/api/chat/",{params:{"question":self.question}}).then(function (rs){
              console.log(rs.data);
              if (rs.data.code===200){
                  self.answer= rs.data.data;
              }else{
                //清空答案
                self.answer="";
                //提示
                self.$message.error(rs.data.msg);
              }

          })
       }
  }
}
</script>

<template>

  <div>
      <div>{{answer}}</div>
      <el-input v-model="question"></el-input>
      <el-button type="info" @click="sendInfo">发送</el-button>
  </div>

</template>

<style scoped>

</style>
